//
//  ViewController.m
//  DYAutoLayoutGradientColor
//
//  Created by 黄德玉 on 2017/11/29.
//  Copyright © 2017年 none. All rights reserved.
//

#import "ViewController.h"
#import "DYGradientView.h"
#import "DYGradientBtn.h"
#import "DYGradientLabel.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
        UIColor * leftColor = [UIColor colorWithRed:0x44/255.0 green:0x8d/255.0 blue:0xfa/255.0 alpha:1];
        UIColor * rightColor = [UIColor colorWithRed:0x38/255.0 green:0x5c/255.0 blue:0x9a/255.0 alpha:1];
    
    DYGradientLabel  * gradientView = [[DYGradientLabel alloc] init];
    gradientView.translatesAutoresizingMaskIntoConstraints = NO;
//    [gradientView addGradientWithStartPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 1) colors:@[(__bridge id)[UIColor redColor].CGColor,(__bridge id)[UIColor greenColor].CGColor] locations:nil];
    [gradientView addColors:@[(__bridge id)leftColor.CGColor,(__bridge id)rightColor.CGColor]];
    [self.view addSubview:gradientView];
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:gradientView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:gradientView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
    [gradientView addConstraint:[NSLayoutConstraint constraintWithItem:gradientView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:200]];
    [gradientView addConstraint:[NSLayoutConstraint constraintWithItem:gradientView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:100]];
    
    
//    DYGradientBtn * gradientView = [DYGradientBtn buttonWithType:UIButtonTypeSystem];
//    [gradientView setTitle:@"你好" forState:UIControlStateNormal];
//    [gradientView addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
//    gradientView.translatesAutoresizingMaskIntoConstraints = NO;

//    [gradientView addColors:@[(__bridge id)leftColor.CGColor,(__bridge id)rightColor.CGColor]];
//    [self.view addSubview:gradientView];
//    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:gradientView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
//    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:gradientView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
//    [gradientView addConstraint:[NSLayoutConstraint constraintWithItem:gradientView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:200]];
//    [gradientView addConstraint:[NSLayoutConstraint constraintWithItem:gradientView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:100]];
}


- (void)btnClicked{
    NSLog(@"按钮点击");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
